<!DOCTYPE html>
<html class="x-admin-sm">
{include file='public/header'}
<style>
    .updateSet .layui-form-label{
        width: 115px;
    }
    .updateSet .layui-input-block{
        margin-left: 145px;
    }
    #link_switch,#is_open,#echo_rate,#echo_rule_config_id,#is_open_low_recharge_not_echo,#not_echo_recharge_price,#remark{
        display: none;
    }
</style>
<body>
    <div class="x-body updateSet" >
        <form class="layui-form" lay-filter="batchUpdateSet">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>选项
                </label>
                <div class="layui-input-block">
                    <input type="checkbox" value="link_switch" title="是否开启投放" lay-skin="primary" lay-filter="option">
                    <input type="checkbox" value="is_open" title="回传开关" lay-skin="primary" lay-filter="option"> 
                    <!-- <input type="checkbox" value="echo_rate" title="回传率" lay-skin="primary" lay-filter="option"> 
                    <input type="checkbox" value="echo_rule_config_id" title="回传规则配置" lay-skin="primary" lay-filter="option"> 
                    <input type="checkbox" value="is_open_low_recharge_not_echo" title="低充值不回传" lay-skin="primary" lay-filter="option"> 
                    <input type="checkbox" value="not_echo_recharge_price" title="低于此金额不回传" lay-skin="primary" lay-filter="option">  -->
                    <input type="checkbox" value="remark" title="备注" lay-skin="primary" lay-filter="option"> 
                </div>
            </div>
            <div class="layui-form-item" id="link_switch">
                <label class="layui-form-label">
                    是否开启投放
                </label>
                <div class="layui-input-block">
                    <input type="radio" name="link_switch" value="1" title="开启" checked>
                    <input type="radio" name="link_switch" value="0" title="关闭">
                </div>
            </div>
            <div class="layui-form-item" id="is_open">
                <label class="layui-form-label">
                    回传开关
                </label>
                <div class="layui-input-block">
                    <input type="radio" name="is_open" value="1" title="开启" checked>
                    <input type="radio" name="is_open" value="2" title="关闭">
                </div>
            </div>
            <!-- <div class="layui-form-item" id="echo_rate">
                <label class="layui-form-label">
                    回传率
                </label>
                <div class="layui-input-block">
                    <input type="number" name="echo_rate" autocomplete="off" class="layui-input" value="" placeholder="请输入0~100之间的整数" />
                </div>
            </div>
            <div class="layui-form-item" id="echo_rule_config_id">
                <label class="layui-form-label">
                    回传规则配置
                </label>
                <div class="layui-input-block">
                    <input type="radio" name="echo_rule_config_id"  lay-filter="echo_rule_config_id" value="0" title="按公共配置回传（T+7全量）" checked>
                    <input type="radio" name="echo_rule_config_id"  lay-filter="echo_rule_config_id" value="1" title="按自然日配置回传" >
                    <input type="radio" name="echo_rule_config_id"  lay-filter="echo_rule_config_id" value="2" title="仅回传首单（T+7全量）" >
                </div>
            </div>
            <div class="layui-form-item" id="is_open_low_recharge_not_echo">
                <label class="layui-form-label">
                    低充值不回传
                </label>
                <div class="layui-input-block">
                    <input type="radio" name="is_open_low_recharge_not_echo" value="0" title="关闭" checked>
                    <input type="radio" name="is_open_low_recharge_not_echo" value="1" title="开启">
                </div>
            </div>
            <div class="layui-form-item" id="not_echo_recharge_price">
                <label class="layui-form-label">
                    <span class="x-red"></span>低于此金额不回传
                </label>
                <div class="layui-input-block">
                    <input type="number" name="not_echo_recharge_price" autocomplete="off" class="layui-input" value="" placeholder="小于该值的支付金额将不回传" />
                </div>
            </div> -->

            <div class="layui-form-item" id="remark">
                <label class="layui-form-label">
                    备注
                </label>
                <div class="layui-input-block">
                    <input type="text" name="remark" value="" class="layui-input"/>
                </div>
            </div>
            <button id="submitData" class="layui-btn" lay-submit lay-filter="submitData" style="display: none;" />
        </form>
    </div>
    <script>
        let params = {
            batchUpdateSet: 'cps/back/batchUpdateSet'
        }
        
        let link_ids = GetQueryString('link_ids')
        layui.use(["form", "layer"], function () {
            var form = layui.form,
                layer = layui.layer;
            form.render();
            form.on('checkbox(option)', function(data){
                $('#'+data.value).css('display',data.elem.checked ? 'block' : "none")
            });
            form.on('submit(submitData)', function(data){
                var formData = data.field;
                
                let submitForm = {};
                $(".layui-form-item").each((index,item)=>{
                    if($(item).css('display') == 'block' && $(item).attr('id')){
                        submitForm[$(item).attr('id')] = formData[$(item).attr('id')]
                    }
                })
                for (let index = 0; index < Object.keys(submitForm).length; index++) {
                    const element = Object.values(submitForm)[index];
                    if(element == ''){
                        layer.msg('请填写完整！',{icon:5,time:1000});
                        return false;
                    }
                }
                submitForm.link_ids = link_ids;
                layer.confirm('请确认内容是否正确！', function () {
                    formReloadAjax("/cps/back/batchUpdateSet",submitForm)
                });
                return false
            });
        });
    </script>
</body>

</html>